<?php
define('IN_ECTOUCH', true);
require(dirname(__FILE__) . '/include/init.php');
if ($_REQUEST['act'] == 'loveSupport')
{
   include('include/cls_json.php');
   $json   = new JSON;
   $res    = array('err_msg' => '', 'result' => '', 'qty' => 1);
   $time = gmtime();
   $time = local_date('Y-m-d', $time);
   $time1 = local_date('H:i:s', gmtime());
   $ip = real_ip();
   
   if(empty($_SESSION['user_id']))
	{
		$res['error']  = 1;//没有登陆
		$res['message']  = '您还没有登陆,请登陆后再来签到';
		die($json->encode($res));
	}
   
   $id_value     = (isset($_REQUEST['id_value'])) ? intval($_REQUEST['id_value']) : 0;
   $type     = (isset($_REQUEST['type'])) ? intval($_REQUEST['type']) : 0;
   
	//判断当天是否已经签过到了
	$sql = "select count(*) from " .$ecs->table('love_log'). " where time='$time' and ip='$ip' and type=$type and id_value=$id_value";
	$count = $db->getOne($sql);
	if($count>=1)//更改1天点击数。如果是改成10,那就是2.4个小时可以点
	{
		$res['error']  = 2;//签到成功
		$res['err_msg']  = '';//请不要再签到了
		$res['id_value'] = $id_value;
	}
	else
	{
		$custom_points = 5;
		$sql = "insert into " .$ecs->table('love_log'). "(time,id_value,ip,type) values('$time','$id_value','$ip',$type)";
		$db->query($sql);
		$res['error']  = 0;
		log_account_change($_SESSION['user_id'], 0, 0, intval($custom_points), intval($custom_points), "分享送积分");
		$res['err_msg']  = '恭喜，您分享获得'.$custom_points.'积分';
   }
  
   die($json->encode($res));
}
?>